/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package data.Imp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author admin
 */
public class ConnectionManager {
    public static Connection connect;
    protected static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    protected static final String DATABASE_URL = "jdbc:mysql://localhost:8889/dbdanangcuisine";
    protected static final String USERNAME = "root";
    protected static final String PASSWORD = "root";

    public static Connection getConnection(){// throws SQLException, ClassNotFoundException {
        try {
            Class.forName(JDBC_DRIVER);
            try {
                if (connect == null) {
                    connect = DriverManager.getConnection(DATABASE_URL, USERNAME, PASSWORD);
                }
            } catch (SQLException e) {
                System.out.println(e.getMessage());
            }
        } catch (ClassNotFoundException e) {
            System.out.println(e.getMessage());
        }      
        return connect;
    }
//    public static void main(String[] args) throws SQLException, ClassNotFoundException {
//        Connection cnn = getConnection();
//    }
}
